Phenology_vids¶

Purpose: Create time lapse videos of a region for any location¶

Steps:¶

  1. Link to DataCube
  2. Specify time frame, central location, buffer size
  3. Download Sentinel data
  4. Generate indices as needed.
  5. Resample weekly???
  6. run xr_animation and save plots
    • option to load polygon data (e.g. cadastrals)???
    • if loading cadastrals, show trace plots of indices within polygons???import matplotlib.pyplot as plt
In [1]:
%matplotlib inline

import os
import datacube
import numpy as np
import pandas as pd
import xarray as xr
import datetime as dt
import matplotlib.pyplot as plt

import sys
sys.path.insert(1, '../Tools/')
from dea_tools.temporal import xr_phenology, temporal_statistics
from dea_tools.datahandling import load_ard
from dea_tools.bandindices import calculate_indices
from dea_tools.plotting import display_map, rgb
from dea_tools.dask import create_local_dask_cluster

from dea_tools.plotting import display_map, rgb, xr_animation
import skimage

# Plot animation
from IPython.display import Image
from IPython.core.display import Video

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

# Create local dask cluster to improve data load time
client = create_local_dask_cluster(return_client=True)
2024-07-18 16:58:22,389 - distributed.nanny.memory - WARNING - Ignoring provided memory limit 131415622144 due to system memory limit of 32.00 GiB

Client

Client-1e6bbd08-44d3-11ef-aeaa-000007aafe80

Connection method: Cluster object Cluster type: distributed.LocalCluster
Dashboard: /proxy/8787/status

Cluster Info

LocalCluster

c5c93198

Dashboard: /proxy/8787/status Workers: 1
Total threads: 7 Total memory: 32.00 GiB
Status: running Using processes: True

Scheduler Info

Scheduler

Scheduler-301331e6-d4ee-4234-b16c-4da46ec8d636

Comm: tcp://127.0.0.1:37955 Workers: 1
Dashboard: /proxy/8787/status Total threads: 7
Started: Just now Total memory: 32.00 GiB

Workers

Worker: 0

Comm: tcp://127.0.0.1:43577 Total threads: 7
Dashboard: /proxy/45029/status Memory: 32.00 GiB
Nanny: tcp://127.0.0.1:38609
Local directory: /jobfs/121050713.gadi-pbs/dask-scratch-space/worker-6_b4avf1
In [2]:
dc = datacube.Datacube(app='Vegetation_phenology')
In [3]:
# Define area of interest

# # 186 Milgadara Rd, Barwang NSW: -34.38904277303204, 148.46949938279096
# Yelkin -33.47904684379098, 146.3094839864518
# Boomahnoomoona -36.11965805095775, 146.08472404116773
# Adam O'tool site: -33.5040228817206, 148.6385170105664
# Grant Sims multispecies cover crop experiment sites -36.22746736927963, 144.40088864017818
# Spring Valley farm: -35.284243390317, 149.0074353022316

#stub = 'ADAMO'
#stub = "SPRVAL"
stub = "MILG_24"

lat = -34.38904277303204
lon = 148.46949938279096
lon_buffer = 0.01
lat_buffer = 0.01

# Set the range of dates for the analysis
time_range = ('2024-01-01', '2024-08-01') # when is the earliest? 2016?

# Combine central lat,lon with buffer to get area of interest
lat_range = (lat-lat_buffer, lat+lat_buffer)
lon_range = (lon-lon_buffer, lon+lon_buffer)

display_map(x=lon_range, y=lat_range)
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Load sentinel data raw¶

In [4]:
# Create a reusable query
query = {
    'y': lat_range,
    'x': lon_range,
    'time': time_range,
    'measurements': ['nbart_red', 'nbart_green', 'nbart_blue', 'nbart_nir_1'],
    'resolution': (-20, 20),
    'output_crs': 'epsg:6933',
    'group_by':'solar_day'
}

# Load available data from Sentinel-2
ds = load_ard(
    dc=dc,
    products=['ga_s2am_ard_3', 'ga_s2bm_ard_3'],
    cloud_mask='s2cloudless',
    min_gooddata=0.9,
    **query,
)

# Shut down Dask client now that we have loaded the data we need
client.close()

# Preview data
ds
Finding datasets
    ga_s2am_ard_3
    ga_s2bm_ard_3
Counting good quality pixels for each time step using s2cloudless
/g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/rasterio/warp.py:344: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
  _reproject(
/g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/rasterio/warp.py:344: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
  _reproject(
Filtering to 33 out of 89 time steps with at least 90.0% good quality pixels
Applying s2cloudless pixel quality/cloud mask
Loading 33 time steps
Out[4]:
<xarray.Dataset>
Dimensions:      (time: 33, y: 106, x: 97)
Coordinates:
  * time         (time) datetime64[ns] 2023-01-09T00:06:28.779134 ... 2024-03...
  * y            (y) float64 -4.227e+06 -4.227e+06 ... -4.229e+06 -4.23e+06
  * x            (x) float64 1.438e+07 1.438e+07 ... 1.438e+07 1.438e+07
    spatial_ref  int32 6933
Data variables:
    nbart_red    (time, y, x) float32 616.0 706.0 939.0 ... 597.0 622.0 731.0
    nbart_green  (time, y, x) float32 496.0 627.0 745.0 ... 535.0 542.0 631.0
    nbart_blue   (time, y, x) float32 340.0 413.0 457.0 ... 401.0 414.0 459.0
    nbart_nir_1  (time, y, x) float32 2.303e+03 2.616e+03 ... 1.838e+03 2e+03
Attributes:
    crs:           epsg:6933
    grid_mapping:  spatial_ref
xarray.Dataset
    • time: 33
    • y: 106
    • x: 97
    • time
      (time)
      datetime64[ns]
      2023-01-09T00:06:28.779134 ... 2...
      units :
      seconds since 1970-01-01 00:00:00
      array(['2023-01-09T00:06:28.779134000', '2023-01-14T00:06:29.174460000',
             '2023-02-18T00:06:30.318962000', '2023-03-10T00:06:35.935435000',
             '2023-03-15T00:06:29.028576000', '2023-03-30T00:06:35.284870000',
             '2023-04-09T00:06:34.117432000', '2023-04-24T00:06:31.380180000',
             '2023-05-04T00:06:32.258679000', '2023-05-09T00:06:34.668919000',
             '2023-05-19T00:06:36.721392000', '2023-05-29T00:06:36.281595000',
             '2023-07-23T00:06:36.388965000', '2023-08-07T00:06:37.085585000',
             '2023-09-01T00:06:37.096650000', '2023-09-06T00:06:36.477585000',
             '2023-09-11T00:06:36.851212000', '2023-09-16T00:06:40.273374000',
             '2023-09-21T00:06:33.736265000', '2023-10-01T00:06:34.062549000',
             '2023-10-11T00:06:30.534103000', '2023-10-26T00:06:32.647955000',
             '2023-10-31T00:06:31.280205000', '2023-11-10T00:06:31.347728000',
             '2023-12-15T00:06:30.617134000', '2023-12-30T00:06:29.036935000',
             '2024-01-19T00:06:22.896921000', '2024-02-13T00:06:32.896737000',
             '2024-02-18T00:06:29.875046000', '2024-02-28T00:06:31.402157000',
             '2024-03-04T00:06:28.213493000', '2024-03-24T00:06:32.416874000',
             '2024-03-29T00:06:31.937507000'], dtype='datetime64[ns]')
    • y
      (y)
      float64
      -4.227e+06 -4.227e+06 ... -4.23e+06
      units :
      metre
      resolution :
      -20.0
      crs :
      epsg:6933
      array([-4227410., -4227430., -4227450., -4227470., -4227490., -4227510.,
             -4227530., -4227550., -4227570., -4227590., -4227610., -4227630.,
             -4227650., -4227670., -4227690., -4227710., -4227730., -4227750.,
             -4227770., -4227790., -4227810., -4227830., -4227850., -4227870.,
             -4227890., -4227910., -4227930., -4227950., -4227970., -4227990.,
             -4228010., -4228030., -4228050., -4228070., -4228090., -4228110.,
             -4228130., -4228150., -4228170., -4228190., -4228210., -4228230.,
             -4228250., -4228270., -4228290., -4228310., -4228330., -4228350.,
             -4228370., -4228390., -4228410., -4228430., -4228450., -4228470.,
             -4228490., -4228510., -4228530., -4228550., -4228570., -4228590.,
             -4228610., -4228630., -4228650., -4228670., -4228690., -4228710.,
             -4228730., -4228750., -4228770., -4228790., -4228810., -4228830.,
             -4228850., -4228870., -4228890., -4228910., -4228930., -4228950.,
             -4228970., -4228990., -4229010., -4229030., -4229050., -4229070.,
             -4229090., -4229110., -4229130., -4229150., -4229170., -4229190.,
             -4229210., -4229230., -4229250., -4229270., -4229290., -4229310.,
             -4229330., -4229350., -4229370., -4229390., -4229410., -4229430.,
             -4229450., -4229470., -4229490., -4229510.])
    • x
      (x)
      float64
      1.438e+07 1.438e+07 ... 1.438e+07
      units :
      metre
      resolution :
      20.0
      crs :
      epsg:6933
      array([14376210., 14376230., 14376250., 14376270., 14376290., 14376310.,
             14376330., 14376350., 14376370., 14376390., 14376410., 14376430.,
             14376450., 14376470., 14376490., 14376510., 14376530., 14376550.,
             14376570., 14376590., 14376610., 14376630., 14376650., 14376670.,
             14376690., 14376710., 14376730., 14376750., 14376770., 14376790.,
             14376810., 14376830., 14376850., 14376870., 14376890., 14376910.,
             14376930., 14376950., 14376970., 14376990., 14377010., 14377030.,
             14377050., 14377070., 14377090., 14377110., 14377130., 14377150.,
             14377170., 14377190., 14377210., 14377230., 14377250., 14377270.,
             14377290., 14377310., 14377330., 14377350., 14377370., 14377390.,
             14377410., 14377430., 14377450., 14377470., 14377490., 14377510.,
             14377530., 14377550., 14377570., 14377590., 14377610., 14377630.,
             14377650., 14377670., 14377690., 14377710., 14377730., 14377750.,
             14377770., 14377790., 14377810., 14377830., 14377850., 14377870.,
             14377890., 14377910., 14377930., 14377950., 14377970., 14377990.,
             14378010., 14378030., 14378050., 14378070., 14378090., 14378110.,
             14378130.])
    • spatial_ref
      ()
      int32
      6933
      spatial_ref :
      PROJCS["WGS 84 / NSIDC EASE-Grid 2.0 Global",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Cylindrical_Equal_Area"],PARAMETER["standard_parallel_1",30],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","6933"]]
      grid_mapping_name :
      lambert_cylindrical_equal_area
      array(6933, dtype=int32)
    • nbart_red
      (time, y, x)
      float32
      616.0 706.0 939.0 ... 622.0 731.0
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[ 616.,  706.,  939., ...,  722.,  715.,  842.],
              [ 805.,  848., 1144., ...,  615.,  714.,  856.],
              [ 621.,  766., 1142., ...,  754.,  702.,  685.],
              ...,
              [ 642., 1074., 1139., ...,  477.,  445.,  471.],
              [ 704.,  702.,  704., ...,  537.,  567.,  717.],
              [ 618.,  662.,  572., ...,  652.,  677.,  776.]],
      
             [[ 746.,  771., 1024., ...,  863.,  806.,  969.],
              [ 928.,  982., 1265., ...,  770.,  799., 1006.],
              [ 751.,  880., 1271., ...,  876.,  809.,  827.],
              ...,
              [ 828., 1278., 1331., ...,  570.,  527.,  558.],
              [ 856.,  832.,  800., ...,  630.,  651.,  800.],
              [ 715.,  792.,  715., ...,  736.,  787.,  887.]],
      
             [[ 591.,  682.,  842., ...,  675.,  620.,  727.],
              [ 771.,  817.,  976., ...,  590.,  609.,  738.],
              [ 653.,  717.,  935., ...,  731.,  677.,  663.],
              ...,
      ...
              ...,
              [ 629.,  942.,  957., ...,  527.,  495.,  500.],
              [ 683.,  665.,  603., ...,  542.,  561.,  662.],
              [ 612.,  629.,  521., ...,  608.,  631.,  764.]],
      
             [[ 440.,  540.,  802., ...,  621.,  609.,  816.],
              [ 928.,  744.,  844., ...,  624.,  744.,  838.],
              [ 628.,  735.,  860., ...,  711.,  796.,  840.],
              ...,
              [ 620.,  988.,  947., ...,  521.,  476.,  473.],
              [ 575.,  665.,  560., ...,  535.,  509.,  585.],
              [ 643.,  637.,  435., ...,  583.,  610.,  728.]],
      
             [[ 464.,  613.,  855., ...,  669.,  665.,  790.],
              [ 930.,  770.,  848., ...,  677.,  749.,  854.],
              [ 684.,  735.,  879., ...,  762.,  823.,  868.],
              ...,
              [ 676., 1003.,  997., ...,  539.,  523.,  522.],
              [ 612.,  655.,  628., ...,  573.,  567.,  619.],
              [ 711.,  713.,  491., ...,  597.,  622.,  731.]]], dtype=float32)
    • nbart_green
      (time, y, x)
      float32
      496.0 627.0 745.0 ... 542.0 631.0
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[496., 627., 745., ..., 596., 577., 678.],
              [688., 626., 836., ..., 670., 662., 717.],
              [558., 636., 824., ..., 668., 658., 678.],
              ...,
              [544., 771., 786., ..., 425., 427., 426.],
              [676., 630., 541., ..., 475., 466., 537.],
              [550., 586., 557., ..., 530., 511., 591.]],
      
             [[621., 713., 820., ..., 681., 647., 753.],
              [785., 749., 930., ..., 736., 737., 814.],
              [644., 737., 913., ..., 749., 736., 760.],
              ...,
              [674., 872., 933., ..., 505., 509., 498.],
              [742., 690., 612., ..., 530., 541., 634.],
              [600., 672., 653., ..., 575., 597., 669.]],
      
             [[519., 598., 706., ..., 558., 542., 595.],
              [686., 651., 784., ..., 593., 601., 658.],
              [588., 633., 770., ..., 653., 616., 639.],
              ...,
      ...
              ...,
              [502., 720., 765., ..., 433., 427., 441.],
              [656., 599., 528., ..., 460., 452., 539.],
              [565., 613., 500., ..., 500., 503., 573.]],
      
             [[421., 516., 647., ..., 516., 558., 641.],
              [754., 635., 670., ..., 594., 623., 664.],
              [547., 618., 662., ..., 657., 651., 670.],
              ...,
              [506., 751., 741., ..., 426., 430., 437.],
              [523., 569., 497., ..., 470., 440., 460.],
              [533., 533., 376., ..., 497., 511., 568.]],
      
             [[450., 537., 691., ..., 541., 572., 649.],
              [765., 649., 719., ..., 602., 659., 678.],
              [596., 644., 727., ..., 674., 687., 693.],
              ...,
              [557., 778., 772., ..., 489., 496., 482.],
              [546., 583., 563., ..., 493., 476., 540.],
              [596., 589., 438., ..., 535., 542., 631.]]], dtype=float32)
    • nbart_blue
      (time, y, x)
      float32
      340.0 413.0 457.0 ... 414.0 459.0
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[340., 413., 457., ..., 317., 279., 392.],
              [437., 376., 503., ..., 322., 318., 407.],
              [305., 389., 508., ..., 368., 324., 371.],
              ...,
              [382., 528., 521., ..., 266., 266., 295.],
              [449., 421., 400., ..., 332., 305., 371.],
              [355., 350., 305., ..., 337., 359., 403.]],
      
             [[428., 446., 543., ..., 403., 394., 465.],
              [518., 466., 622., ..., 417., 427., 496.],
              [432., 469., 598., ..., 446., 419., 454.],
              ...,
              [465., 641., 684., ..., 363., 373., 390.],
              [538., 501., 467., ..., 405., 393., 452.],
              [470., 453., 433., ..., 416., 450., 454.]],
      
             [[374., 398., 513., ..., 391., 363., 422.],
              [473., 452., 543., ..., 373., 371., 444.],
              [395., 420., 522., ..., 430., 404., 399.],
              ...,
      ...
              ...,
              [363., 500., 531., ..., 315., 290., 304.],
              [410., 433., 387., ..., 318., 315., 370.],
              [386., 391., 299., ..., 364., 364., 430.]],
      
             [[296., 361., 479., ..., 371., 363., 458.],
              [519., 435., 459., ..., 399., 424., 445.],
              [373., 432., 493., ..., 415., 464., 491.],
              ...,
              [381., 546., 527., ..., 332., 330., 312.],
              [357., 394., 353., ..., 342., 323., 357.],
              [400., 365., 273., ..., 353., 392., 436.]],
      
             [[375., 431., 518., ..., 403., 410., 486.],
              [573., 506., 533., ..., 424., 471., 494.],
              [415., 496., 506., ..., 469., 492., 517.],
              ...,
              [441., 583., 563., ..., 360., 370., 376.],
              [421., 451., 392., ..., 395., 368., 399.],
              [456., 448., 346., ..., 401., 414., 459.]]], dtype=float32)
    • nbart_nir_1
      (time, y, x)
      float32
      2.303e+03 2.616e+03 ... 2e+03
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[2303., 2616., 2547., ..., 2401., 2644., 2619.],
              [2695., 2643., 2679., ..., 3352., 3094., 2847.],
              [2776., 2767., 2799., ..., 2749., 2947., 3006.],
              ...,
              [2101., 2527., 2564., ..., 2196., 2149., 1975.],
              [2232., 1990., 1814., ..., 2241., 2264., 2367.],
              [2162., 2556., 2494., ..., 2156., 2221., 2294.]],
      
             [[2282., 2777., 2683., ..., 2459., 2600., 2620.],
              [2833., 2775., 2865., ..., 3350., 3149., 2882.],
              [2797., 2862., 2953., ..., 2802., 2935., 2894.],
              ...,
              [2231., 2742., 2669., ..., 2238., 2184., 2044.],
              [2297., 2020., 1808., ..., 2225., 2304., 2381.],
              [2157., 2520., 2384., ..., 2184., 2212., 2357.]],
      
             [[1966., 2460., 2274., ..., 1871., 2015., 2032.],
              [2617., 2339., 2274., ..., 2737., 2756., 2278.],
              [2510., 2507., 2476., ..., 2272., 2327., 2362.],
              ...,
      ...
              ...,
              [1937., 2530., 2335., ..., 1847., 1863., 1772.],
              [2301., 2077., 1816., ..., 1835., 1910., 1995.],
              [2036., 2505., 1963., ..., 1899., 1926., 2095.]],
      
             [[1626., 2206., 2358., ..., 1777., 2102., 2021.],
              [2726., 2243., 2149., ..., 2322., 2076., 2036.],
              [2293., 2571., 2316., ..., 2248., 2091., 2053.],
              ...,
              [1995., 2561., 2262., ..., 1779., 1825., 1743.],
              [1800., 2037., 1611., ..., 1753., 1819., 1884.],
              [1938., 2256., 1503., ..., 1830., 1825., 2004.]],
      
             [[1724., 2333., 2418., ..., 1792., 2083., 2044.],
              [2798., 2416., 2247., ..., 2355., 2162., 2085.],
              [2347., 2657., 2464., ..., 2288., 2113., 2104.],
              ...,
              [1989., 2558., 2282., ..., 1756., 1830., 1800.],
              [1900., 2095., 1573., ..., 1719., 1860., 1884.],
              [1950., 2305., 1539., ..., 1853., 1838., 2000.]]], dtype=float32)
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2023-01-09 00:06:28.779134', '2023-01-14 00:06:29.174460',
                     '2023-02-18 00:06:30.318962', '2023-03-10 00:06:35.935435',
                     '2023-03-15 00:06:29.028576', '2023-03-30 00:06:35.284870',
                     '2023-04-09 00:06:34.117432', '2023-04-24 00:06:31.380180',
                     '2023-05-04 00:06:32.258679', '2023-05-09 00:06:34.668919',
                     '2023-05-19 00:06:36.721392', '2023-05-29 00:06:36.281595',
                     '2023-07-23 00:06:36.388965', '2023-08-07 00:06:37.085585',
                     '2023-09-01 00:06:37.096650', '2023-09-06 00:06:36.477585',
                     '2023-09-11 00:06:36.851212', '2023-09-16 00:06:40.273374',
                     '2023-09-21 00:06:33.736265', '2023-10-01 00:06:34.062549',
                     '2023-10-11 00:06:30.534103', '2023-10-26 00:06:32.647955',
                     '2023-10-31 00:06:31.280205', '2023-11-10 00:06:31.347728',
                     '2023-12-15 00:06:30.617134', '2023-12-30 00:06:29.036935',
                     '2024-01-19 00:06:22.896921', '2024-02-13 00:06:32.896737',
                     '2024-02-18 00:06:29.875046', '2024-02-28 00:06:31.402157',
                     '2024-03-04 00:06:28.213493', '2024-03-24 00:06:32.416874',
                     '2024-03-29 00:06:31.937507'],
                    dtype='datetime64[ns]', name='time', freq=None))
    • y
      PandasIndex
      PandasIndex(Index([-4227410.0, -4227430.0, -4227450.0, -4227470.0, -4227490.0, -4227510.0,
             -4227530.0, -4227550.0, -4227570.0, -4227590.0,
             ...
             -4229330.0, -4229350.0, -4229370.0, -4229390.0, -4229410.0, -4229430.0,
             -4229450.0, -4229470.0, -4229490.0, -4229510.0],
            dtype='float64', name='y', length=106))
    • x
      PandasIndex
      PandasIndex(Index([14376210.0, 14376230.0, 14376250.0, 14376270.0, 14376290.0, 14376310.0,
             14376330.0, 14376350.0, 14376370.0, 14376390.0, 14376410.0, 14376430.0,
             14376450.0, 14376470.0, 14376490.0, 14376510.0, 14376530.0, 14376550.0,
             14376570.0, 14376590.0, 14376610.0, 14376630.0, 14376650.0, 14376670.0,
             14376690.0, 14376710.0, 14376730.0, 14376750.0, 14376770.0, 14376790.0,
             14376810.0, 14376830.0, 14376850.0, 14376870.0, 14376890.0, 14376910.0,
             14376930.0, 14376950.0, 14376970.0, 14376990.0, 14377010.0, 14377030.0,
             14377050.0, 14377070.0, 14377090.0, 14377110.0, 14377130.0, 14377150.0,
             14377170.0, 14377190.0, 14377210.0, 14377230.0, 14377250.0, 14377270.0,
             14377290.0, 14377310.0, 14377330.0, 14377350.0, 14377370.0, 14377390.0,
             14377410.0, 14377430.0, 14377450.0, 14377470.0, 14377490.0, 14377510.0,
             14377530.0, 14377550.0, 14377570.0, 14377590.0, 14377610.0, 14377630.0,
             14377650.0, 14377670.0, 14377690.0, 14377710.0, 14377730.0, 14377750.0,
             14377770.0, 14377790.0, 14377810.0, 14377830.0, 14377850.0, 14377870.0,
             14377890.0, 14377910.0, 14377930.0, 14377950.0, 14377970.0, 14377990.0,
             14378010.0, 14378030.0, 14378050.0, 14378070.0, 14378090.0, 14378110.0,
             14378130.0],
            dtype='float64', name='x'))
  • crs :
    epsg:6933
    grid_mapping :
    spatial_ref
In [ ]:
 
In [5]:
# Calculate the chosen vegetation proxy index and add it to the loaded data set
ds = calculate_indices(ds, index=['NDVI','NDWI'], collection='ga_s2_3')
In [6]:
ds_weekly = ds.resample(time="1W").interpolate("linear")
In [7]:
path_animations = '/home/jovyan/Projects/PaddockTS/Results/'
num_frames = 20
num_frames = len(ds_weekly.time) # get total length from ds_weekly
In [10]:
num_frames
Out[10]:
64
In [11]:
# Create animation of weekly resampled NDVI
output = path_animations+stub+'_NDVI_weekly_nomarkup.mp4'

ds_ = ds_weekly.interpolate_na(dim = 'time', method = 'linear')

xr_animation(ds_, 
             bands=['NDVI'], 
             output_path = output, 
             #show_gdf = gdf_, 
             #gdf_kwargs={"edgecolor": 'blue'},
             #gdf_kwargs={"edgecolor": pol['color_edge']}, # Make edge color something different
             show_text="NDVI",
             imshow_kwargs={"cmap": "Greens", "vmin": 0.0, "vmax": 1.0},
             limit=num_frames)

plt.close()
Video(output, embed=True)
Exporting animation to /home/jovyan/Projects/PaddockTS/Results/SPRVAL_NDVI_weekly_nomarkup.mp4
  0%|          | 0/64 (0.0 seconds remaining at ? frames/s)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[11], line 6
      2 output = path_animations+stub+'_NDVI_weekly_nomarkup.mp4'
      4 ds_ = ds_weekly.interpolate_na(dim = 'time', method = 'linear')
----> 6 xr_animation(ds_, 
      7              bands=['NDVI'], 
      8              output_path = output, 
      9              #show_gdf = gdf_, 
     10              #gdf_kwargs={"edgecolor": 'blue'},
     11              #gdf_kwargs={"edgecolor": pol['color_edge']}, # Make edge color something different
     12              show_text="NDVI",
     13              imshow_kwargs={"cmap": "Greens", "vmin": 0.0, "vmax": 1.0},
     14              limit=num_frames)
     16 plt.close()
     17 Video(output, embed=True)

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/dea_tools/plotting.py:741, in xr_animation(ds, bands, output_path, width_pixels, interval, percentile_stretch, image_proc_funcs, show_gdf, show_date, show_text, show_colorbar, gdf_kwargs, annotation_kwargs, imshow_kwargs, colorbar_kwargs, limit)
    739     anim.save(output_path, writer='pillow')
    740 else:
--> 741     anim.save(output_path, dpi=72)
    743 # Update progress bar to fix progress bar moving past end
    744 if progress_bar.n != len(ds.time):

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/animation.py:1089, in Animation.save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs, progress_callback)
   1085 savefig_kwargs['transparent'] = False   # just to be safe!
   1086 # canvas._is_saving = True makes the draw_event animation-starting
   1087 # callback a no-op; canvas.manager = None prevents resizing the GUI
   1088 # widget (both are likewise done in savefig()).
-> 1089 with writer.saving(self._fig, filename, dpi), \
   1090      cbook._setattr_cm(self._fig.canvas, _is_saving=True, manager=None):
   1091     for anim in all_anim:
   1092         anim._init_draw()  # Clear the initial frame

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.__enter__(self)
    133 del self.args, self.kwds, self.func
    134 try:
--> 135     return next(self.gen)
    136 except StopIteration:
    137     raise RuntimeError("generator didn't yield") from None

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/animation.py:240, in AbstractMovieWriter.saving(self, fig, outfile, dpi, *args, **kwargs)
    235     _log.info("Disabling savefig.bbox = 'tight', as it may cause "
    236               "frame size to vary, which is inappropriate for "
    237               "animation.")
    239 # This particular sequence is what contextlib.contextmanager wants
--> 240 self.setup(fig, outfile, dpi, *args, **kwargs)
    241 with mpl.rc_context({'savefig.bbox': None}):
    242     try:

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/animation.py:327, in MovieWriter.setup(self, fig, outfile, dpi)
    325 def setup(self, fig, outfile, dpi=None):
    326     # docstring inherited
--> 327     super().setup(fig, outfile, dpi=dpi)
    328     self._w, self._h = self._adjust_frame_size()
    329     # Run here so that grab_frame() can write the data to a pipe. This
    330     # eliminates the need for temp files.

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/animation.py:195, in AbstractMovieWriter.setup(self, fig, outfile, dpi)
    181 """
    182 Setup for writing the movie file.
    183 
   (...)
    192     in pixels of the resulting movie file.
    193 """
    194 # Check that path is valid
--> 195 Path(outfile).parent.resolve(strict=True)
    196 self.outfile = outfile
    197 self.fig = fig

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/pathlib.py:1077, in Path.resolve(self, strict)
   1074         raise RuntimeError("Symlink loop from %r" % e.filename)
   1076 try:
-> 1077     s = self._accessor.realpath(self, strict=strict)
   1078 except OSError as e:
   1079     check_eloop(e)

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/posixpath.py:395, in realpath(filename, strict)
    392     """Return the canonical path of the specified filename, eliminating any
    393 symbolic links encountered in the path."""
    394     filename = os.fspath(filename)
--> 395     path, ok = _joinrealpath(filename[:0], filename, strict, {})
    396     return abspath(path)

File /g/data/v10/public/modules/dea/20231204/lib/python3.10/posixpath.py:430, in _joinrealpath(path, rest, strict, seen)
    428 newpath = join(path, name)
    429 try:
--> 430     st = os.lstat(newpath)
    431 except OSError:
    432     if strict:

FileNotFoundError: [Errno 2] No such file or directory: '/home/jovyan'
No description has been provided for this image
In [23]:
# Create animation of weekly resampled NDVI

output = path_animations+stub+'_NDVI_nomarkup.mp4'


ds_ = ds.interpolate_na(dim = 'time', method = 'linear')

xr_animation(ds_, 
             bands=['NDVI'], 
             #bands=['nbart_red', 'nbart_green', 'nbart_blue'], 
             output_path = output, 
             show_text="NDVI",
             imshow_kwargs={"cmap": "Greens", "vmin": 0.0, "vmax": 1.0},
             limit=num_frames)

plt.close()
Video(output, embed=True)
Exporting animation to /home/jovyan/Projects/PaddockTS/Results/SPRVAL_NDVI_nomarkup.mp4
  0%|          | 0/216 (0.0 seconds remaining at ? frames/s)
Out[23]:
Your browser does not support the video tag.
In [24]:
# RGB actual time series

output = path_animations+stub+'_RGB_nomarkup.mp4'

ds_ = ds.interpolate_na(dim = 'time', method = 'linear')

xr_animation(ds_, 
             bands=['nbart_red', 'nbart_green', 'nbart_blue'], 
             output_path = output, 
             limit=num_frames)

plt.close()
Video(output, embed=True)
Exporting animation to /home/jovyan/Projects/PaddockTS/Results/SPRVAL_RGB_nomarkup.mp4
  0%|          | 0/216 (0.0 seconds remaining at ? frames/s)
Out[24]:
Your browser does not support the video tag.
In [25]:
# RGB weekly resampled time series

output = path_animations+stub+'_RGB_weekly_nomarkup.mp4'

ds_ = ds_weekly.interpolate_na(dim = 'time', method = 'linear')

xr_animation(ds_, 
             bands=['nbart_red', 'nbart_green', 'nbart_blue'], 
             output_path = output, 
             limit=num_frames)

plt.close()
Video(output, embed=True)
Exporting animation to /home/jovyan/Projects/PaddockTS/Results/SPRVAL_RGB_weekly_nomarkup.mp4
  0%|          | 0/378 (0.0 seconds remaining at ? frames/s)
Out[25]:
Your browser does not support the video tag.
In [ ]:
 
In [13]:
ds_weekly
Out[13]:
<xarray.Dataset>
Dimensions:      (time: 368, y: 322, x: 290)
Coordinates:
  * y            (y) float64 -4.037e+06 -4.037e+06 ... -4.043e+06 -4.043e+06
  * x            (x) float64 1.434e+07 1.434e+07 ... 1.434e+07 1.434e+07
    spatial_ref  int32 6933
  * time         (time) datetime64[ns] 2017-03-12 2017-03-19 ... 2024-03-24
Data variables:
    nbart_red    (time, y, x) float64 2.1e+03 2.06e+03 1.997e+03 ... nan nan nan
    nbart_green  (time, y, x) float64 1.43e+03 1.393e+03 1.323e+03 ... nan nan
    nbart_blue   (time, y, x) float64 1.034e+03 973.2 939.5 ... nan nan nan
    nbart_nir_1  (time, y, x) float64 3.251e+03 3.23e+03 3.18e+03 ... nan nan
    NDVI         (time, y, x) float64 0.2195 0.2235 0.2322 ... nan nan nan
    NDWI         (time, y, x) float64 -0.3911 -0.3983 -0.4132 ... nan nan nan
Attributes:
    crs:           epsg:6933
    grid_mapping:  spatial_ref
xarray.Dataset
    • time: 368
    • y: 322
    • x: 290
    • y
      (y)
      float64
      -4.037e+06 ... -4.043e+06
      units :
      metre
      resolution :
      -20.0
      crs :
      epsg:6933
      array([-4037050., -4037070., -4037090., ..., -4043430., -4043450., -4043470.])
    • x
      (x)
      float64
      1.434e+07 1.434e+07 ... 1.434e+07
      units :
      metre
      resolution :
      20.0
      crs :
      epsg:6933
      array([14338690., 14338710., 14338730., ..., 14344430., 14344450., 14344470.])
    • spatial_ref
      ()
      int32
      6933
      spatial_ref :
      PROJCS["WGS 84 / NSIDC EASE-Grid 2.0 Global",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Cylindrical_Equal_Area"],PARAMETER["standard_parallel_1",30],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","6933"]]
      grid_mapping_name :
      lambert_cylindrical_equal_area
      array(6933, dtype=int32)
    • time
      (time)
      datetime64[ns]
      2017-03-12 ... 2024-03-24
      units :
      seconds since 1970-01-01 00:00:00
      array(['2017-03-12T00:00:00.000000000', '2017-03-19T00:00:00.000000000',
             '2017-03-26T00:00:00.000000000', ..., '2024-03-10T00:00:00.000000000',
             '2024-03-17T00:00:00.000000000', '2024-03-24T00:00:00.000000000'],
            dtype='datetime64[ns]')
    • nbart_red
      (time, y, x)
      float64
      2.1e+03 2.06e+03 ... nan nan
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[2100.41342767, 2059.87087625, 1997.32913196, ...,
               1599.71221901, 1616.66550764, 1633.03919861],
              [1966.2539633 , 1980.71194997, 1998.03919861, ...,
               1572.55329273, 1597.04859469, 1661.52537353],
              [1842.82389583, 1773.47812407, 1696.20644479, ...,
               1669.29181668, 1684.61879627, 1709.46926608],
              ...,
              [1573.60027315, 1585.53503866, 1582.23597827, ...,
               2040.78792577, 1793.39490455, 2201.96591326],
              [1524.56268882, 1596.73101118, 1631.74980335, ...,
               2074.48913443, 1726.85262217, 2159.14336266],
              [1660.93691788, 1726.98389829, 1782.45155009, ...,
               2081.41423481, 1863.47920025, 2017.00295951]],
      
             [[1792.39595498, 1820.80731506, 1714.86310872, ...,
               1329.84691056, 1344.3500602 , 1380.32486307],
              [1739.7911169 , 1748.29876603, 1745.32486307, ...,
               1309.33836153, 1337.33386204, 1381.85950913],
              [1638.76232018, 1566.26636972, 1579.64983297, ...,
               1377.37525734, 1409.85320984, 1434.35365979],
      ...
              [1068.44517486,  999.48545455,  932.42055949, ...,
               1545.80097883, 1264.21930056, 1470.56601394],
              [ 898.49888112,  834.51230768,  852.98209791, ...,
               1586.9285312 , 1286.66447542, 1669.14097893],
              [ 937.48993008,  913.02461537,  866.96867135, ...,
               1470.75174809, 1316.12307685, 1750.64209781]],
      
             [[          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              ...,
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan]]])
    • nbart_green
      (time, y, x)
      float64
      1.43e+03 1.393e+03 ... nan nan
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[1430.33772091, 1392.52429735, 1323.33745186, ...,
               1050.08510284, 1081.87946519, 1098.98228402],
              [1300.65503538, 1329.93557265, 1340.79543853, ...,
               1067.9916801 , 1078.729935  , 1118.49637814],
              [1247.97288793, 1198.80456557, 1115.23409495, ...,
               1159.26282129, 1143.54308951, 1149.92617656],
              ...,
              [1035.62684713, 1048.03812243, 1047.72026987, ...,
               1399.11356014, 1225.86094207, 1484.49691623],
              [1014.61745104, 1045.71087378, 1077.6735585 , ...,
               1401.98282211, 1146.57100872, 1419.11356014],
              [1121.1691295 , 1196.01047227, 1184.3750362 , ...,
               1372.0201374 , 1238.8421499 , 1331.59946601]],
      
             [[1253.22767412, 1262.66693102, 1183.67952959, ...,
                912.17727985,  948.17188046,  963.17458015],
              [1185.14848312, 1191.67772979, 1195.18717872, ...,
                925.18357913,  944.67233041,  972.18807862],
              [1119.16558118, 1083.64803317, 1052.58054084, ...,
               1000.70382683,  999.68492898, 1018.66873082],
      ...
              [ 799.04251746,  736.04475522,  673.5055944 , ...,
                966.23272713,  856.5973426 , 1014.12531461],
              [ 644.53916081,  614.50783216,  612.00671328, ...,
                964.24391593,  857.59958036, 1126.09398596],
              [ 677.54139858,  660.52349649,  653.02013985, ...,
               1021.13426565,  929.6197202 , 1179.08279715]],
      
             [[          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              ...,
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan]]])
    • nbart_blue
      (time, y, x)
      float64
      1.034e+03 973.2 939.5 ... nan nan
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[1034.10389501,  973.24376008,  939.50550518, ...,
                774.0848338 ,  767.06604163,  769.86980006],
              [ 921.9073844 ,  929.06631068,  934.51490126, ...,
                752.46792085,  774.36510202,  789.81369261],
              [ 865.26255224,  827.1970487 ,  783.7014777 , ...,
                811.3744981 ,  818.46792085,  849.44000164],
              ...,
              [ 680.86980006,  684.72026987,  680.92590752, ...,
                965.12241813,  850.02872634, 1041.74872716],
              [ 657.44912868,  700.21557183,  690.15946437, ...,
                981.62711617,  821.17825654,  996.8421499 ],
              [ 782.61772009,  803.88886128,  835.11329109, ...,
                994.78604245,  882.55221655,  950.97288793]],
      
             [[ 882.1952778 ,  866.13768435,  823.64893307, ...,
                673.62913532,  680.61113736,  680.61473696],
              [ 804.65073286,  805.15928189,  811.65793204, ...,
                664.61293716,  688.61023747,  705.10888762],
              [ 744.1556823 ,  717.64083399,  708.09718895, ...,
                718.61923644,  730.61293716,  745.13408476],
      ...
              [ 567.48993008,  551.9597203 ,  504.97314687, ...,
                615.64209781,  609.52797201,  674.52573425],
              [ 490.48097903,  460.54811186,  471.98209791, ...,
                620.65328662,  599.52573425,  760.06489506],
              [ 498.48993008,  510.48769232,  481.46979023, ...,
                711.56825171,  652.07608387,  807.53916081]],
      
             [[          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              ...,
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan]]])
    • nbart_nir_1
      (time, y, x)
      float64
      3.251e+03 3.23e+03 ... nan nan
      units :
      1
      nodata :
      -999
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[3250.64671548, 3230.32886292, 3180.32913196, ...,
               2326.31087789, 2406.6005422 , 2383.36698534],
              [3058.2534252 , 3058.68349267, 3097.74899621, ...,
               2343.02094453, 2345.85289122, 2417.89960259],
              [2893.15060638, 2757.11302205, 2684.69208162, ...,
               2540.56322691, 2506.37638143, 2479.46013904],
              ...,
              [2722.57879052, 2788.23301876, 2843.16751522, ...,
               3220.18013986, 2951.43195079, 3382.23678541],
              [2664.8593278 , 2769.23301876, 2873.53207915, ...,
               3279.41342767, 2817.02067549, 3293.93745597],
              [2850.87838901, 2906.37396001, 3029.6730204 , ...,
               3285.36698534, 2995.58175003, 3149.54443474]],
      
             [[2992.33206225, 2985.31496419, 2897.86310872, ...,
               1982.94139982, 2070.93150094, 2035.44724915],
              [2906.69482785, 2884.72362458, 2912.23847289, ...,
               2029.40315417, 2008.43375069, 2082.93060105],
              [2743.69212816, 2635.65613225, 2616.08818997, ...,
               2195.44364956, 2151.45624813, 2173.89280534],
      ...
              [1777.28867115, 1636.33566413, 1689.85916061, ...,
               2191.90839135, 2031.82335644, 2497.31104876],
              [1472.73384601, 1377.68237751, 1489.78979003, ...,
               2214.55496469, 2023.81664316, 2558.77188794],
              [1488.7114684 , 1502.22601384, 1554.84349629, ...,
               2402.41622352, 2184.80097883, 2563.67342646]],
      
             [[          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              ...,
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan],
              [          nan,           nan,           nan, ...,
                         nan,           nan,           nan]]])
    • NDVI
      (time, y, x)
      float64
      0.2195 0.2235 0.2322 ... nan nan
      array([[[0.21948746, 0.22349775, 0.23215258, ..., 0.18756751,
               0.19958382, 0.18778591],
              [0.22022888, 0.2168121 , 0.21926317, ..., 0.20038094,
               0.19202711, 0.18874489],
              [0.22435227, 0.22018444, 0.22661906, ..., 0.21131827,
               0.19846235, 0.18754622],
              ...,
              [0.27320784, 0.28187487, 0.29146444, ..., 0.23296643,
               0.25181756, 0.22101658],
              [0.27741349, 0.27355727, 0.28089606, ..., 0.23660269,
               0.24635467, 0.21768534],
              [0.27152357, 0.26422461, 0.27108637, ..., 0.23412904,
               0.24123458, 0.229407  ]],
      
             [[0.26075094, 0.24716001, 0.26456468, ..., 0.20295636,
               0.22025231, 0.194036  ],
              [0.2572894 , 0.25149586, 0.25797397, ..., 0.22399448,
               0.20548184, 0.21005592],
              [0.25759835, 0.26101756, 0.24904085, ..., 0.2390655 ,
               0.21375732, 0.21347197],
      ...
              [0.24744249, 0.23908919, 0.28593356, ..., 0.17301728,
               0.23311053, 0.25805765],
              [0.24068788, 0.24456146, 0.26949857, ..., 0.16559573,
               0.22227559, 0.21021493],
              [0.22599244, 0.2427442 , 0.28098071, ..., 0.24050925,
               0.24762441, 0.18854502]],
      
             [[       nan,        nan,        nan, ...,        nan,
                      nan,        nan],
              [       nan,        nan,        nan, ...,        nan,
                      nan,        nan],
              [       nan,        nan,        nan, ...,        nan,
                      nan,        nan],
              ...,
              [       nan,        nan,        nan, ...,        nan,
                      nan,        nan],
              [       nan,        nan,        nan, ...,        nan,
                      nan,        nan],
              [       nan,        nan,        nan, ...,        nan,
                      nan,        nan]]])
    • NDWI
      (time, y, x)
      float64
      -0.3911 -0.3983 -0.4132 ... nan nan
      array([[[-0.39113185, -0.39829006, -0.41316926, ..., -0.37649664,
               -0.3784074 , -0.36683875],
              [-0.40441647, -0.3956395 , -0.39772269, ..., -0.37378658,
               -0.36829575, -0.36677038],
              [-0.39903728, -0.39547446, -0.41351318, ..., -0.37342198,
               -0.37202254, -0.3656635 ],
              ...,
              [-0.4489294 , -0.45383712, -0.46133492, ..., -0.39629593,
               -0.41494651, -0.39159784],
              [-0.44875271, -0.45172749, -0.45455988, ..., -0.40459524,
               -0.42217264, -0.399068  ],
              [-0.43692587, -0.41941851, -0.44063886, ..., -0.41358859,
               -0.41537342, -0.40796935]],
      
             [[-0.41452475, -0.40710972, -0.42180721, ..., -0.36644016,
               -0.36885446, -0.35304924],
              [-0.42323233, -0.41897586, -0.42203532, ..., -0.37370493,
               -0.35631444, -0.36205048],
              [-0.42425779, -0.42053826, -0.42717597, ..., -0.37398833,
               -0.36240184, -0.36037094],
      ...
              [-0.37850117, -0.37749955, -0.42746684, ..., -0.38904756,
               -0.40632018, -0.42237713],
              [-0.39008823, -0.38210808, -0.41549108, ..., -0.3933789 ,
               -0.40424874, -0.38860829],
              [-0.37364415, -0.38805555, -0.4058403 , ..., -0.40290027,
               -0.40292056, -0.36995398]],
      
             [[        nan,         nan,         nan, ...,         nan,
                       nan,         nan],
              [        nan,         nan,         nan, ...,         nan,
                       nan,         nan],
              [        nan,         nan,         nan, ...,         nan,
                       nan,         nan],
              ...,
              [        nan,         nan,         nan, ...,         nan,
                       nan,         nan],
              [        nan,         nan,         nan, ...,         nan,
                       nan,         nan],
              [        nan,         nan,         nan, ...,         nan,
                       nan,         nan]]])
    • y
      PandasIndex
      PandasIndex(Float64Index([-4037050.0, -4037070.0, -4037090.0, -4037110.0, -4037130.0,
                    -4037150.0, -4037170.0, -4037190.0, -4037210.0, -4037230.0,
                    ...
                    -4043290.0, -4043310.0, -4043330.0, -4043350.0, -4043370.0,
                    -4043390.0, -4043410.0, -4043430.0, -4043450.0, -4043470.0],
                   dtype='float64', name='y', length=322))
    • x
      PandasIndex
      PandasIndex(Float64Index([14338690.0, 14338710.0, 14338730.0, 14338750.0, 14338770.0,
                    14338790.0, 14338810.0, 14338830.0, 14338850.0, 14338870.0,
                    ...
                    14344290.0, 14344310.0, 14344330.0, 14344350.0, 14344370.0,
                    14344390.0, 14344410.0, 14344430.0, 14344450.0, 14344470.0],
                   dtype='float64', name='x', length=290))
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2017-03-12', '2017-03-19', '2017-03-26', '2017-04-02',
                     '2017-04-09', '2017-04-16', '2017-04-23', '2017-04-30',
                     '2017-05-07', '2017-05-14',
                     ...
                     '2024-01-21', '2024-01-28', '2024-02-04', '2024-02-11',
                     '2024-02-18', '2024-02-25', '2024-03-03', '2024-03-10',
                     '2024-03-17', '2024-03-24'],
                    dtype='datetime64[ns]', name='time', length=368, freq=None))
  • crs :
    epsg:6933
    grid_mapping :
    spatial_ref
In [ ]:
 

Load a different dataset (fractional cover)¶

https://knowledge.dea.ga.gov.au/notebooks/DEA_products/DEA_Fractional_Cover/

In [18]:
import datacube
from datacube.utils import masking
import matplotlib.pyplot as plt

import sys
sys.path.insert(1, '../Tools/')
from dea_tools.datahandling import wofs_fuser
from dea_tools.plotting import rgb, plot_wo
In [13]:
stub = "MILG_24"

lat = -34.38904
lon = 148.46949
lon_buffer = 0.01
lat_buffer = 0.01

# Set the range of dates for the analysis
time_range = ('2020-01-01', '2022-01-01')

# Combine central lat,lon with buffer to get area of interest
lat_range = (lat-lat_buffer, lat+lat_buffer)
lon_range = (lon-lon_buffer, lon+lon_buffer)

display_map(x=lon_range, y=lat_range)
Out[13]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [14]:
# Create a reusable query
query = {
    'y': lat_range,
    'x': lon_range,
    'time': time_range,
    'output_crs': 'epsg:6933',
    'group_by':'solar_day'
}

# Load available data from 
fc = dc.load(product='ga_ls_fc_3',
             measurements=['bs', 'pv', 'npv', 'ue'],
             resolution=(-30, 30),
             **query)


# Shut down Dask client now that we have loaded the data we need
client.close()

# Preview data
fc
Out[14]:
<xarray.Dataset>
Dimensions:      (time: 87, y: 71, x: 66)
Coordinates:
  * time         (time) datetime64[ns] 2020-01-07T23:56:40.592891 ... 2021-12...
  * y            (y) float64 -4.133e+06 -4.133e+06 ... -4.135e+06 -4.135e+06
  * x            (x) float64 1.432e+07 1.432e+07 ... 1.433e+07 1.433e+07
    spatial_ref  int32 6933
Data variables:
    bs           (time, y, x) uint8 18 19 19 19 17 17 18 ... 49 47 48 51 52 50
    pv           (time, y, x) uint8 13 13 13 13 13 13 14 ... 43 38 35 35 32 30
    npv          (time, y, x) uint8 68 67 66 67 68 69 67 ... 5 6 14 15 13 14 19
    ue           (time, y, x) uint8 7 7 7 7 7 7 7 7 7 7 ... 8 9 12 9 7 6 6 5 5 4
Attributes:
    crs:           epsg:6933
    grid_mapping:  spatial_ref
xarray.Dataset
    • time: 87
    • y: 71
    • x: 66
    • time
      (time)
      datetime64[ns]
      2020-01-07T23:56:40.592891 ... 2...
      units :
      seconds since 1970-01-01 00:00:00
      array(['2020-01-07T23:56:40.592891000', '2020-01-15T23:36:37.299972000',
             '2020-01-23T23:56:36.765939000', '2020-01-31T23:35:49.563423000',
             '2020-02-08T23:56:31.774346000', '2020-02-16T23:35:00.185191000',
             '2020-02-24T23:56:28.025939000', '2020-03-11T23:56:21.709961000',
             '2020-03-19T23:33:16.693207000', '2020-03-27T23:56:12.950767000',
             '2020-04-04T23:32:22.651879000', '2020-04-12T23:56:05.537842000',
             '2020-04-20T23:31:26.933654000', '2020-04-28T23:55:57.771957000',
             '2020-05-06T23:30:29.419702000', '2020-05-14T23:55:53.708486000',
             '2020-05-22T23:29:30.106112000', '2020-05-30T23:55:57.827887000',
             '2020-06-07T23:28:33.975590000', '2020-06-15T23:56:07.884384000',
             '2020-06-23T23:27:37.622834000', '2020-07-01T23:56:15.840033000',
             '2020-07-09T23:26:39.972095000', '2020-07-17T23:56:21.842655000',
             '2020-08-02T23:56:25.926343000', '2020-08-10T23:24:40.734966000',
             '2020-08-18T23:56:31.483901000', '2020-08-26T23:23:39.058611000',
             '2020-09-03T23:56:39.275670000', '2020-09-11T23:22:35.911983000',
             '2020-09-19T23:56:44.894850000', '2020-09-27T23:21:33.061255000',
             '2020-10-05T23:56:48.154753000', '2020-10-13T23:20:31.813154000',
             '2020-10-21T23:56:48.757284000', '2020-10-29T23:19:28.651798000',
             '2020-11-14T23:18:23.017501000', '2020-11-22T23:56:48.113626000',
             '2020-11-30T23:17:14.552037000', '2020-12-08T23:56:49.888886000',
             '2020-12-24T23:56:47.633269000', '2021-01-01T23:14:54.016914000',
             '2021-01-09T23:56:41.733458000', '2021-01-17T23:13:46.507726000',
             '2021-01-25T23:56:37.058284000', '2021-02-02T23:12:36.737783000',
             '2021-02-10T23:56:34.438050000', '2021-02-18T23:11:24.835078000',
             '2021-02-26T23:56:28.771593000', '2021-03-06T23:10:10.779990000',
             '2021-03-14T23:56:19.784663000', '2021-03-30T23:56:15.474637000',
             '2021-04-07T23:07:35.765985000', '2021-04-15T23:56:09.706964000',
             '2021-04-23T23:06:14.810625000', '2021-05-01T23:56:00.643016000',
             '2021-05-09T23:04:54.547865000', '2021-05-17T23:56:05.605969000',
             '2021-05-25T23:03:32.925359000', '2021-06-02T23:56:14.166762000',
             '2021-06-10T23:02:13.115821000', '2021-06-18T23:56:19.901505000',
             '2021-07-04T23:56:22.809747000', '2021-07-12T22:59:33.097703000',
             '2021-07-20T23:56:26.354214000', '2021-07-28T22:58:10.010159000',
             '2021-08-05T23:56:34.176701000', '2021-08-13T22:56:44.797315000',
             '2021-08-21T23:56:39.356954000', '2021-08-29T22:55:21.690613000',
             '2021-09-06T23:56:44.086237000', '2021-09-14T22:53:57.449660000',
             '2021-09-22T23:56:46.575464000', '2021-09-30T22:52:31.469342000',
             '2021-10-08T23:56:52.696210000', '2021-10-16T22:51:06.861482000',
             '2021-10-24T23:56:54.703826000', '2021-11-01T22:49:38.800494000',
             '2021-11-09T23:56:51.790286000', '2021-11-11T23:53:32.239342000',
             '2021-11-17T22:48:06.090470000', '2021-11-21T23:58:27.154074000',
             '2021-11-25T23:56:49.928821000', '2021-12-03T22:46:35.079661000',
             '2021-12-11T23:56:49.839301000', '2021-12-19T22:45:03.270021000',
             '2021-12-27T23:56:44.912679000'], dtype='datetime64[ns]')
    • y
      (y)
      float64
      -4.133e+06 ... -4.135e+06
      units :
      metre
      resolution :
      -30.0
      crs :
      epsg:6933
      array([-4133265., -4133295., -4133325., -4133355., -4133385., -4133415.,
             -4133445., -4133475., -4133505., -4133535., -4133565., -4133595.,
             -4133625., -4133655., -4133685., -4133715., -4133745., -4133775.,
             -4133805., -4133835., -4133865., -4133895., -4133925., -4133955.,
             -4133985., -4134015., -4134045., -4134075., -4134105., -4134135.,
             -4134165., -4134195., -4134225., -4134255., -4134285., -4134315.,
             -4134345., -4134375., -4134405., -4134435., -4134465., -4134495.,
             -4134525., -4134555., -4134585., -4134615., -4134645., -4134675.,
             -4134705., -4134735., -4134765., -4134795., -4134825., -4134855.,
             -4134885., -4134915., -4134945., -4134975., -4135005., -4135035.,
             -4135065., -4135095., -4135125., -4135155., -4135185., -4135215.,
             -4135245., -4135275., -4135305., -4135335., -4135365.])
    • x
      (x)
      float64
      1.432e+07 1.432e+07 ... 1.433e+07
      units :
      metre
      resolution :
      30.0
      crs :
      epsg:6933
      array([14324295., 14324325., 14324355., 14324385., 14324415., 14324445.,
             14324475., 14324505., 14324535., 14324565., 14324595., 14324625.,
             14324655., 14324685., 14324715., 14324745., 14324775., 14324805.,
             14324835., 14324865., 14324895., 14324925., 14324955., 14324985.,
             14325015., 14325045., 14325075., 14325105., 14325135., 14325165.,
             14325195., 14325225., 14325255., 14325285., 14325315., 14325345.,
             14325375., 14325405., 14325435., 14325465., 14325495., 14325525.,
             14325555., 14325585., 14325615., 14325645., 14325675., 14325705.,
             14325735., 14325765., 14325795., 14325825., 14325855., 14325885.,
             14325915., 14325945., 14325975., 14326005., 14326035., 14326065.,
             14326095., 14326125., 14326155., 14326185., 14326215., 14326245.])
    • spatial_ref
      ()
      int32
      6933
      spatial_ref :
      PROJCS["WGS 84 / NSIDC EASE-Grid 2.0 Global",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Cylindrical_Equal_Area"],PARAMETER["standard_parallel_1",30],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","6933"]]
      grid_mapping_name :
      lambert_cylindrical_equal_area
      array(6933, dtype=int32)
    • bs
      (time, y, x)
      uint8
      18 19 19 19 17 ... 47 48 51 52 50
      units :
      percent
      nodata :
      255
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[ 18,  19,  19, ...,  21,  25,  34],
              [ 18,  19,  19, ...,  19,  23,  28],
              [ 21,  20,  18, ...,  25,  23,  24],
              ...,
              [ 36,  39,  40, ...,  31,  31,  30],
              [ 38,  40,  42, ...,  32,  33,  32],
              [ 36,  39,  41, ...,  32,  32,  32]],
      
             [[  1,   1,   0, ...,   6,   3,   7],
              [  0,   0,   0, ..., 255, 255, 255],
              [  0,   0,   0, ...,   0,   3,   2],
              ...,
              [ 17,  16,  15, ...,  36,  48,  53],
              [ 20,  24,  15, ...,  33,  45,  43],
              [  9,  18,   5, ...,  25,  33,  39]],
      
             [[ 23,  24,  25, ...,  25,  34,  40],
              [ 25,  24,  24, ...,  22,  30,  36],
              [ 27,  24,  24, ...,  26,  28,  32],
              ...,
      ...
              ...,
              [  9,   8,   9, ...,  14,  17,  15],
              [  9,   9,   9, ...,  17,  16,  15],
              [  9,   9,   9, ...,  16,  14,  14]],
      
             [[ 12,  12,   9, ...,   8,  12,   5],
              [  7,  10,  10, ...,   9,   8,   7],
              [  7,   6,  10, ...,   8,   6,   4],
              ...,
              [  3,   3,   2, ...,  13,  10,  12],
              [  0,   3,   5, ...,  18,  17,   5],
              [  3,   7,   3, ...,  13,  13,  17]],
      
             [[ 27,  31,  37, ...,  26,  31,  39],
              [ 13,  20,  38, ...,  22,  32,  40],
              [ 44,  41,  38, ...,  21,  26,  44],
              ...,
              [ 54,  55,  57, ...,  53,  54,  54],
              [ 29,  15,  14, ...,  46,  51,  52],
              [ 24,  35,  24, ...,  51,  52,  50]]], dtype=uint8)
    • pv
      (time, y, x)
      uint8
      13 13 13 13 13 ... 38 35 35 32 30
      units :
      percent
      nodata :
      255
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[ 13,  13,  13, ...,  16,  13,  10],
              [ 13,  13,  13, ...,  18,  14,  12],
              [ 13,  13,  13, ...,  15,  14,  13],
              ...,
              [ 10,  10,  11, ...,  11,  10,   9],
              [ 10,  11,  11, ...,  10,  10,  10],
              [ 10,  10,  11, ...,  10,  10,  10]],
      
             [[ 32,  32,  30, ...,  35,  35,  36],
              [ 31,  31,  30, ..., 255, 255, 255],
              [ 30,  30,  29, ...,  35,  36,  34],
              ...,
              [ 40,  40,  39, ...,  45,  46,  46],
              [ 40,  42,  41, ...,  44,  44,  44],
              [ 39,  40,  39, ...,  43,  43,  43]],
      
             [[ 12,  12,  13, ...,  16,  11,   9],
              [ 12,  12,  12, ...,  18,  13,  10],
              [ 13,  11,  13, ...,  16,  14,  11],
              ...,
      ...
              ...,
              [ 77,  77,  75, ...,  46,  47,  49],
              [ 79,  78,  78, ...,  45,  46,  49],
              [ 82,  82,  79, ...,  46,  48,  51]],
      
             [[ 42,  43,  43, ...,  61,  69,  58],
              [ 46,  47,  47, ...,  66,  76,  64],
              [ 47,  49,  46, ...,  67,  73,  61],
              ...,
              [ 78,  78,  74, ...,  40,  39,  45],
              [ 82,  80,  81, ...,  39,  38,  41],
              [ 79,  79,  79, ...,  38,  38,  47]],
      
             [[ 46,  43,  40, ...,  45,  45,  43],
              [ 42,  42,  40, ...,  46,  44,  40],
              [ 40,  41,  40, ...,  49,  44,  39],
              ...,
              [ 38,  45,  43, ...,  31,  30,  31],
              [ 50,  61,  59, ...,  31,  31,  31],
              [ 57,  53,  51, ...,  35,  32,  30]]], dtype=uint8)
    • npv
      (time, y, x)
      uint8
      68 67 66 67 68 ... 14 15 13 14 19
      units :
      percent
      nodata :
      255
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[ 68,  67,  66, ...,  61,  61,  55],
              [ 67,  67,  66, ...,  62,  61,  58],
              [ 65,  65,  67, ...,  59,  61,  61],
              ...,
              [ 52,  49,  47, ...,  57,  57,  59],
              [ 50,  48,  46, ...,  57,  55,  57],
              [ 52,  49,  47, ...,  56,  56,  57]],
      
             [[ 67,  67,  70, ...,  58,  61,  55],
              [ 69,  69,  70, ..., 255, 255, 255],
              [ 70,  70,  71, ...,  64,  61,  63],
              ...,
              [ 41,  43,  45, ...,  18,   5,   0],
              [ 38,  33,  43, ...,  21,  10,  12],
              [ 51,  42,  55, ...,  30,  23,  17]],
      
             [[ 63,  62,  61, ...,  58,  53,  49],
              [ 62,  62,  62, ...,  58,  55,  53],
              [ 59,  63,  61, ...,  56,  57,  56],
              ...,
      ...
              ...,
              [ 12,  13,  13, ...,  38,  35,  34],
              [ 10,  11,  10, ...,  37,  36,  34],
              [  6,   7,  10, ...,  37,  36,  33]],
      
             [[ 45,  43,  46, ...,  29,  17,  36],
              [ 45,  41,  41, ...,  24,  15,  28],
              [ 44,  44,  41, ...,  23,  19,  33],
              ...,
              [ 17,  18,  22, ...,  45,  49,  41],
              [ 16,  15,  13, ...,  41,  43,  52],
              [ 16,  12,  17, ...,  47,  47,  33]],
      
             [[ 26,  25,  22, ...,  27,  22,  17],
              [ 43,  36,  20, ...,  30,  23,  18],
              [ 15,  17,  20, ...,  28,  29,  15],
              ...,
              [  7,   0,   0, ...,  15,  14,  14],
              [ 19,  23,  25, ...,  21,  17,  16],
              [ 17,  11,  23, ...,  13,  14,  19]]], dtype=uint8)
    • ue
      (time, y, x)
      uint8
      7 7 7 7 7 7 7 7 ... 9 7 6 6 5 5 4
      units :
      1
      nodata :
      255
      crs :
      epsg:6933
      grid_mapping :
      spatial_ref
      array([[[  7,   7,   7, ...,   8,   8,   8],
              [  7,   7,   7, ...,   8,   8,   8],
              [  6,   6,   7, ...,   8,   8,   8],
              ...,
              [  6,   6,   6, ...,   6,   6,   6],
              [  6,   6,   6, ...,   6,   6,   6],
              [  6,   6,   6, ...,   6,   6,   6]],
      
             [[  3,   3,   3, ...,   2,   2,   2],
              [  3,   3,   3, ..., 255, 255, 255],
              [  3,   3,   3, ...,   3,   3,   2],
              ...,
              [  3,   3,   3, ...,   2,   2,   2],
              [  3,   3,   3, ...,   2,   2,   2],
              [  3,   3,   3, ...,   2,   2,   2]],
      
             [[  8,   8,   8, ...,  10,  10,   9],
              [  8,   8,   8, ...,  10,   9,   9],
              [  8,   8,   8, ...,   9,  10,  10],
              ...,
      ...
              ...,
              [ 15,  15,  15, ...,  10,  10,  11],
              [ 16,  16,  15, ...,  10,  10,  10],
              [ 16,  16,  15, ...,  10,  10,  11]],
      
             [[ 11,  11,  12, ...,  13,  13,  13],
              [ 12,  12,  12, ...,  14,  14,  13],
              [ 13,  14,  14, ...,  14,  14,  14],
              ...,
              [ 16,  17,  17, ...,  11,  11,  11],
              [ 17,  17,  16, ...,  10,  10,  11],
              [ 17,  17,  16, ...,  11,  11,  10]],
      
             [[  9,   8,   8, ...,   8,   8,   7],
              [ 10,   9,   7, ...,   9,   8,   7],
              [  8,   8,   8, ...,   9,   8,   7],
              ...,
              [  6,  10,   8, ...,   4,   4,   4],
              [ 12,  16,  16, ...,   5,   5,   4],
              [ 12,  10,  11, ...,   5,   5,   4]]], dtype=uint8)
    • time
      PandasIndex
      PandasIndex(DatetimeIndex(['2020-01-07 23:56:40.592891', '2020-01-15 23:36:37.299972',
                     '2020-01-23 23:56:36.765939', '2020-01-31 23:35:49.563423',
                     '2020-02-08 23:56:31.774346', '2020-02-16 23:35:00.185191',
                     '2020-02-24 23:56:28.025939', '2020-03-11 23:56:21.709961',
                     '2020-03-19 23:33:16.693207', '2020-03-27 23:56:12.950767',
                     '2020-04-04 23:32:22.651879', '2020-04-12 23:56:05.537842',
                     '2020-04-20 23:31:26.933654', '2020-04-28 23:55:57.771957',
                     '2020-05-06 23:30:29.419702', '2020-05-14 23:55:53.708486',
                     '2020-05-22 23:29:30.106112', '2020-05-30 23:55:57.827887',
                     '2020-06-07 23:28:33.975590', '2020-06-15 23:56:07.884384',
                     '2020-06-23 23:27:37.622834', '2020-07-01 23:56:15.840033',
                     '2020-07-09 23:26:39.972095', '2020-07-17 23:56:21.842655',
                     '2020-08-02 23:56:25.926343', '2020-08-10 23:24:40.734966',
                     '2020-08-18 23:56:31.483901', '2020-08-26 23:23:39.058611',
                     '2020-09-03 23:56:39.275670', '2020-09-11 23:22:35.911983',
                     '2020-09-19 23:56:44.894850', '2020-09-27 23:21:33.061255',
                     '2020-10-05 23:56:48.154753', '2020-10-13 23:20:31.813154',
                     '2020-10-21 23:56:48.757284', '2020-10-29 23:19:28.651798',
                     '2020-11-14 23:18:23.017501', '2020-11-22 23:56:48.113626',
                     '2020-11-30 23:17:14.552037', '2020-12-08 23:56:49.888886',
                     '2020-12-24 23:56:47.633269', '2021-01-01 23:14:54.016914',
                     '2021-01-09 23:56:41.733458', '2021-01-17 23:13:46.507726',
                     '2021-01-25 23:56:37.058284', '2021-02-02 23:12:36.737783',
                     '2021-02-10 23:56:34.438050', '2021-02-18 23:11:24.835078',
                     '2021-02-26 23:56:28.771593', '2021-03-06 23:10:10.779990',
                     '2021-03-14 23:56:19.784663', '2021-03-30 23:56:15.474637',
                     '2021-04-07 23:07:35.765985', '2021-04-15 23:56:09.706964',
                     '2021-04-23 23:06:14.810625', '2021-05-01 23:56:00.643016',
                     '2021-05-09 23:04:54.547865', '2021-05-17 23:56:05.605969',
                     '2021-05-25 23:03:32.925359', '2021-06-02 23:56:14.166762',
                     '2021-06-10 23:02:13.115821', '2021-06-18 23:56:19.901505',
                     '2021-07-04 23:56:22.809747', '2021-07-12 22:59:33.097703',
                     '2021-07-20 23:56:26.354214', '2021-07-28 22:58:10.010159',
                     '2021-08-05 23:56:34.176701', '2021-08-13 22:56:44.797315',
                     '2021-08-21 23:56:39.356954', '2021-08-29 22:55:21.690613',
                     '2021-09-06 23:56:44.086237', '2021-09-14 22:53:57.449660',
                     '2021-09-22 23:56:46.575464', '2021-09-30 22:52:31.469342',
                     '2021-10-08 23:56:52.696210', '2021-10-16 22:51:06.861482',
                     '2021-10-24 23:56:54.703826', '2021-11-01 22:49:38.800494',
                     '2021-11-09 23:56:51.790286', '2021-11-11 23:53:32.239342',
                     '2021-11-17 22:48:06.090470', '2021-11-21 23:58:27.154074',
                     '2021-11-25 23:56:49.928821', '2021-12-03 22:46:35.079661',
                     '2021-12-11 23:56:49.839301', '2021-12-19 22:45:03.270021',
                     '2021-12-27 23:56:44.912679'],
                    dtype='datetime64[ns]', name='time', freq=None))
    • y
      PandasIndex
      PandasIndex(Index([-4133265.0, -4133295.0, -4133325.0, -4133355.0, -4133385.0, -4133415.0,
             -4133445.0, -4133475.0, -4133505.0, -4133535.0, -4133565.0, -4133595.0,
             -4133625.0, -4133655.0, -4133685.0, -4133715.0, -4133745.0, -4133775.0,
             -4133805.0, -4133835.0, -4133865.0, -4133895.0, -4133925.0, -4133955.0,
             -4133985.0, -4134015.0, -4134045.0, -4134075.0, -4134105.0, -4134135.0,
             -4134165.0, -4134195.0, -4134225.0, -4134255.0, -4134285.0, -4134315.0,
             -4134345.0, -4134375.0, -4134405.0, -4134435.0, -4134465.0, -4134495.0,
             -4134525.0, -4134555.0, -4134585.0, -4134615.0, -4134645.0, -4134675.0,
             -4134705.0, -4134735.0, -4134765.0, -4134795.0, -4134825.0, -4134855.0,
             -4134885.0, -4134915.0, -4134945.0, -4134975.0, -4135005.0, -4135035.0,
             -4135065.0, -4135095.0, -4135125.0, -4135155.0, -4135185.0, -4135215.0,
             -4135245.0, -4135275.0, -4135305.0, -4135335.0, -4135365.0],
            dtype='float64', name='y'))
    • x
      PandasIndex
      PandasIndex(Index([14324295.0, 14324325.0, 14324355.0, 14324385.0, 14324415.0, 14324445.0,
             14324475.0, 14324505.0, 14324535.0, 14324565.0, 14324595.0, 14324625.0,
             14324655.0, 14324685.0, 14324715.0, 14324745.0, 14324775.0, 14324805.0,
             14324835.0, 14324865.0, 14324895.0, 14324925.0, 14324955.0, 14324985.0,
             14325015.0, 14325045.0, 14325075.0, 14325105.0, 14325135.0, 14325165.0,
             14325195.0, 14325225.0, 14325255.0, 14325285.0, 14325315.0, 14325345.0,
             14325375.0, 14325405.0, 14325435.0, 14325465.0, 14325495.0, 14325525.0,
             14325555.0, 14325585.0, 14325615.0, 14325645.0, 14325675.0, 14325705.0,
             14325735.0, 14325765.0, 14325795.0, 14325825.0, 14325855.0, 14325885.0,
             14325915.0, 14325945.0, 14325975.0, 14326005.0, 14326035.0, 14326065.0,
             14326095.0, 14326125.0, 14326155.0, 14326185.0, 14326215.0, 14326245.0],
            dtype='float64', name='x'))
  • crs :
    epsg:6933
    grid_mapping :
    spatial_ref
In [19]:
# Replace all nodata values with `NaN`
fc = masking.mask_invalid_data(fc)
In [ ]:
 
In [20]:
# Plot DEA Fractional Cover data as a false colour RGB image
rgb(fc, bands=['bs', 'pv', 'npv'], col='time')
/g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/cm.py:494: RuntimeWarning: invalid value encountered in cast
  xx = (xx * 255).astype(np.uint8)
No description has been provided for this image
In [24]:
# Plot unmixing error using `robust=True` to drop outliers and improve contrast
fc.ue.plot(col='time', robust=True, size=5)
Out[24]:
<xarray.plot.facetgrid.FacetGrid at 0x14c6b576c610>
No description has been provided for this image
In [25]:
# Replace all nodata values with `NaN`
fc = masking.mask_invalid_data(fc)
In [27]:
# Load DEA Water Observations data from the datacube
wo = dc.load(product='ga_ls_wo_3',
             group_by='solar_day',
             fuse_func=wofs_fuser,
             like=fc)

# Plot the loaded water observations
plot_wo(wo.water, col='time', size=5)
Out[27]:
<xarray.plot.facetgrid.FacetGrid at 0x14c6b6658490>
No description has been provided for this image
In [29]:
# Keeping only dry, non-cloudy pixels
wo_mask = masking.make_mask(wo.water, dry=True)
wo_mask.plot(col='time', size=5)
Out[29]:
<xarray.plot.facetgrid.FacetGrid at 0x14c6adc8ba00>
No description has been provided for this image
In [30]:
# Set any unclear or wet pixel to `NaN`
fc_masked = fc.where(wo_mask)

# Plot the masked fractional cover data
rgb(fc_masked, bands=['bs', 'pv', 'npv'], col='time')
/g/data/v10/public/modules/dea/20231204/lib/python3.10/site-packages/matplotlib/cm.py:494: RuntimeWarning: invalid value encountered in cast
  xx = (xx * 255).astype(np.uint8)
No description has been provided for this image
In [31]:
# Calculate average fractional cover for `bs`, `pv` and `npv` over time
fc_through_time = fc_masked[['pv', 'npv', 'bs']].mean(dim=['x', 'y'])

# Plot the changing proportions as a line graph
fc_through_time.to_array().plot.line(hue='variable', size=5)
plt.title('Fractional cover over time')
plt.ylabel('Percent cover (%)');
No description has been provided for this image
In [ ]:
### make RGB video
stub = 'MILG_LS_BPN'
path_animations = '/g/data/xe2/John/Data/PadSeg/'
num_frames = len(ds.time) # get total length from ds_weekly
In [10]:
# RGB actual time series

output = path_animations+stub+'_test.mp4'

ds_ = ds.interpolate_na(dim = 'time', method = 'linear')

xr_animation(ds_, 
             bands=['bs', 'pv', 'npv'], 
             output_path = output, 
             limit=num_frames)

plt.close()
Video(output, embed=True)
Exporting animation to /g/data/xe2/John/Data/PadSeg/MILG_LS_BPN_test.mp4
  0%|          | 0/408 (0.0 seconds remaining at ? frames/s)
Out[10]:
Your browser does not support the video tag.
In [11]:
 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[11], line 4
      1 # Load DEA Water Observations data from the datacube
      2 wo = dc.load(product='ga_ls_wo_3',
      3              group_by='solar_day',
----> 4              fuse_func=wofs_fuser,
      5              like=fc)
      7 # Plot the loaded water observations
      8 plot_wo(wo.water, col='time', size=5)

NameError: name 'wofs_fuser' is not defined
In [ ]: